<!--#include file="classData.asp"-->
<%
Response.Buffer = True 
Response.ExpiresAbsolute = Now() - 1 
Response.Expires = 0 
Response.CacheControl = "no-cache" 
Response.AddHeader "Pragma", "No-Cache"



	CurrentGroup = CInt(Request.QueryString("CurrentGroup"))
	maid = CInt(Request.QueryString("maid"))
	mbid = CInt(Request.QueryString("mbid"))
	btype = Request.QueryString("btype")
	R1F = CInt(Request.QueryString("R1F"))
	R1S = CInt(Request.QueryString("R1S"))
	R1FD = CInt(Request.QueryString("R1FD"))
	R1SD = CInt(Request.QueryString("R1SD"))
	
	
	Select Case btype
	
		Case "c5"
			BaseNum = 93100
			CupLevel = "5"
			TarLevel = "51"
		Case "c51"
			BaseNum = 93200
			CupLevel = "51"
			TarLevel = "52"
		Case "c52"
			BaseNum = 93300
			CupLevel = "52"
			TarLevel = "53"
		Case "c53"
			BaseNum = 93500
			CupLevel = "53"
			TarLevel = "55"
		Case "c55"
			CupLevel = "55"
		Case "c15"
			CupLevel = "15"
	
	End Select
	

	set HuaObj = new sysData
	HuaObj.sqlConnOpen()

	set SystemRds=server.CreateObject("ADODB.recordset")
	HuaObj.DbQuery SystemRds,"sysVar",QueryStr,0," VarId = 1"
	
	CurrentSeason = SystemRds("CurrentSeason")

	SystemRds.Close

	SignA = 0
	SignB = 0

	
	TotalFirst = R1F + R1FD
	TotalSecond = R1S + R1SD
	





	HuaObj.p_DbConnection.BeginTrans
	on error resume next


	If TotalFirst > TotalSecond Then
	'Response.Write("a")

		InsertSql = "UPDATE AreaCup SET IfDone = 1,Score = 3,Goal = "&R1F&",Ranking = "&R1FD&" WHERE SeasonNum = "&CurrentSeason&" AND CupLevel = "&CupLevel&" AND ManagerId = "&maid
		HuaObj.SCommand(InsertSql)
		
		InsertSql = "UPDATE AreaCup SET IfDone = 1,Score = 0,Goal = "&R1S&",Ranking = "&R1SD&" WHERE SeasonNum = "&CurrentSeason&" AND CupLevel = "&CupLevel&" AND ManagerId = "&mbid
		HuaObj.SCommand(InsertSql)

		If btype <> "c15" And btype <> "c55" Then
		
			InsertSql = "UPDATE AreaCup SET ManagerId = "&maid&" WHERE SeasonNum = "&CurrentSeason&" AND CupLevel = "&TarLevel&" AND ManagerId = "&(BaseNum + CurrentGroup)
			HuaObj.SCommand(InsertSql)
			
			InsertSql = "UPDATE CupPlan SET HomeId = "&maid&" WHERE SeasonNum = "&CurrentSeason&" AND CupLevel = "&TarLevel&" AND HomeId = "&(BaseNum + CurrentGroup)
			HuaObj.SCommand(InsertSql)
			
			InsertSql = "UPDATE CupPlan SET AwayId = "&maid&" WHERE SeasonNum = "&CurrentSeason&" AND CupLevel = "&TarLevel&" AND AwayId = "&(BaseNum + CurrentGroup)
			HuaObj.SCommand(InsertSql)
		
		End If

	Else
	
	
		InsertSql = "UPDATE AreaCup SET IfDone = 1,Score = 0,Goal = "&R1F&",Ranking = "&R1FD&" WHERE SeasonNum = "&CurrentSeason&" AND CupLevel = "&CupLevel&" AND ManagerId = "&maid
		HuaObj.SCommand(InsertSql)
		
		InsertSql = "UPDATE AreaCup SET IfDone = 1,Score = 3,Goal = "&R1S&",Ranking = "&R1SD&" WHERE SeasonNum = "&CurrentSeason&" AND CupLevel = "&CupLevel&" AND ManagerId = "&mbid
		HuaObj.SCommand(InsertSql)
	
			
		If btype <> "c15" And btype <> "c55" Then
		
			InsertSql = "UPDATE AreaCup SET ManagerId = "&mbid&" WHERE SeasonNum = "&CurrentSeason&" AND CupLevel = "&TarLevel&" AND ManagerId = "&(BaseNum + CurrentGroup)
			HuaObj.SCommand(InsertSql)
			
			InsertSql = "UPDATE CupPlan SET HomeId = "&mbid&" WHERE SeasonNum = "&CurrentSeason&" AND CupLevel = "&TarLevel&" AND HomeId = "&(BaseNum + CurrentGroup)
			HuaObj.SCommand(InsertSql)
			
			InsertSql = "UPDATE CupPlan SET AwayId = "&mbid&" WHERE SeasonNum = "&CurrentSeason&" AND CupLevel = "&TarLevel&" AND AwayId = "&(BaseNum + CurrentGroup)
			HuaObj.SCommand(InsertSql)
		
		End If
			
	
	End If


	InsertSql = "UPDATE CupPlan SET IfDone = 1,HomeScore = "&R1F&",HomePoint = "&R1FD&",AwayScore = "&R1S&",AwayPoint = "&R1SD&",MarkDate = '"&Date&"' WHERE SeasonNum = "&CurrentSeason&" AND CupLevel = "&CupLevel&" AND RoundNum = 1 AND HomeId = "&maid&" AND AwayId = "&mbid
	HuaObj.SCommand(InsertSql)


	response.ContentType="text/xml"	
	Response.Write("<?xml version=""1.0"" encoding=""gb2312""?>"&vbcrlf)
	Response.Write("<xml>"&vbcrlf)


	if err.number =0 then  
    	HuaObj.p_DbConnection.CommitTrans  '如果没有conn错误，则执行事务提交
		Response.Write("<Shi ShiId = ""1"">"&vbcrlf)
		Response.Write("</Shi>"&vbcrlf)
	else 
    	HuaObj.p_DbConnection.RollbackTrans '否则回滚
		Response.Write("<Shi ShiId = ""0"">"&vbcrlf)
		Response.Write("</Shi>"&vbcrlf)
	end if

	Response.Write("</xml>"&vbcrlf)

	
	HuaObj.sqlConnClose()


%>
